﻿
using System.Collections.Generic;

namespace SecondClassAssignment{
    public class Bank{
        private HashSet<Account> _accounts = new HashSet<Account>();

        public bool Add(Account account){
            return _accounts.Add(account);
        }

        public bool Remove(Account account){
            return _accounts.Remove(account);
        }

        public bool Contains(Account account){
            return _accounts.Contains(account);
        }

        public Account IsLegal(Account account){
            if (!Contains(account))
                return null;
            
            foreach (var value in _accounts) {
                if (value.Equals(account) && value.Pwd.Equals(account.Pwd))
                    return value;
            }
            return null;
        }
        
    }
}